/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */




package learn.round1A;


import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.Iterator;
import java.util.Scanner;

/**
 *
 * @author robit
 */
public class MakeitSmooth2 {
    int D,I,M,N;
    int [] pixs;
    MakeitSmooth2(int D,int I,int M,int N,int[] pixs){
        this.D=D;
        this.I=I;
        this.M=M;
        this.N=N;
        this.pixs=pixs;
    }
    int insert(int x,int y){
        int d = Math.abs(x-y);
        if(d<=M)return 0;
        if(M==0)return 255*3;        
        return (d-1)/M*I;
    }
    int change(int x,int y){
        return Math.abs(x-y);
    }
    // small:0 secs,large: 9 secs
    int getMinCostSteal(){
        int min[][]=new int[N+1][256];
        
        for(int i=0;i<=N;i++)
            for(int j=0;j<256;j++)
               if(i==0)min[i][j]=0;else min[i][j]=Integer.MAX_VALUE;

        for(int i=0;i<N;i++){
            //delete
            for(int j=0;j<256;j++)
                min[i+1][j]=Math.min(min[i+1][j],min[i][j]+D);
            //change or insert
            for(int j=0;j<256;j++)
                for(int k=0;k<256;k++){
                    if(Math.abs(j-k)<=M)
                        min[i+1][k]=Math.min(min[i+1][k],min[i][j]+change(pixs[i],k));
                    else if(M!=0)
                        min[i+1][k]=Math.min(min[i+1][k],min[i][j]+change(pixs[i],k)+insert(j, k));
                }
        }
        int ans = Integer.MAX_VALUE;
        for(int i=0;i<256;i++)
            ans=Math.min(ans,min[N][i]);
        return ans;
    }
    // small:0 secs,large: about 2 mins
    int getMinCostLargeInput(){
        int min[][]=new int[N][256];
        for(int i=0;i<256;i++){
          min[0][i]=change(i,pixs[0]);
        }
        for(int k=1;k<N;k++){
            for(int i=0;i<256;i++){
              int addcost=D*k;
              for(int j=0;j<256;j++){
                 for(int l=0;l<k;l++){
                     addcost=Math.min(addcost,insert(i, j)+min[l][j]+(k-1-l)*D);
                 }
              }
              min[k][i]=addcost+change(i, pixs[k]);
            }
        }
        int mincost=N*D;
        for(int k=0;k<N;k++){
            for(int i=0;i<256;i++){
                mincost=Math.min(mincost,min[k][i]+(N-k-1)*D);
            }
        }
        return mincost;
    }
    int getMinCost(){
        
            int min1[] = new int[256];// last elmenent indicate deleted
            int min2[] = new int[256];
            int min3[] = new int[256];

            for(int i=0;i<256;i++){
                min1[i]=change(i,pixs[0]);
            }
            if(N>=2){
                for(int i=0;i<256;i++){
                    int addcost=D;
                    for(int j=0;j<256;j++){
                        addcost = Math.min(addcost,min1[j]+insert(i,j));
                    }
                    min2[i]=addcost+change(i, pixs[1]);
                }
            }
            if(N>=3){
                for(int i=0;i<256;i++){
                    int addcost = 2*D;
                    for(int j=0;j<256;j++){
                        addcost = Math.min(addcost,min1[j] + insert(i, j) +D);
                        addcost = Math.min(addcost,min2[j] + insert(i, j));
                    }
                    min3[i]=addcost+change(i, pixs[2]);
                }
            }

            int mincost=N*D;

            for(int i=0;i<256;i++){                
                mincost=Math.min(mincost, min1[i]+(N-1)*D);
                if(N>=2)mincost=Math.min(mincost, min2[i]+(N-2)*D);
                if(N>=3)mincost=Math.min(mincost, min3[i]);
            }

        return mincost;
    }
    private static Scanner s = null;
    private static PrintWriter o = null;
    /**
    * calculate the answer
    */
    private static int reckon() {
        int D=Int();
        int I=Int();
        int M=Int();
        int N=Int();
        int [] pixs= new int[N];
        for(int i=0;i<N;i++){
            pixs[i]=Int();
        }

        return (new MakeitSmooth2(D, I, M, N, pixs)).getMinCostSteal();
    }


    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException {
        // TODO code application logic here

        try {
            //String filename="test";
            String prob="B";
            //String filename=prob+"-small-practice";
            String filename=prob+"-large-practice";

            s = new Scanner(
                    new BufferedReader(new FileReader(filename+".in")));
            //s.useLocale(Locale.US);
            o = new PrintWriter(
                    new BufferedWriter(new FileWriter(filename+".out")));

            // Determine input line number
            int lineNums = s.nextInt();

            for (int i = 1; i <= lineNums; i++) {
                o.println("Case #" + i + ": " + reckon());
            }
        } finally {
            s.close();
            o.close();
        }
    }


    private static int Int(){
        return s.nextInt();
    }
    private static long Long(){
        return s.nextLong();
    }
    private static String String(){
        return s.next();
    }

}
